﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MVCManage.DAL;
using MVCManage.Model;
using MVCManage.Model.Base;
namespace MVCManage.BLL
{
    public class MessageBLL : BaseBLL<Message>
    {
        public override void SetDal()
        {
            Dal = new MessageDAL();
        }
        public List<Message> GetMessages(int page,int size,out int count) {
            var zhi = Dal.Query();
            count = zhi.Count();
            var pagelist = zhi.OrderBy(n => n.Id).Skip((page - 1) * size).Take(size);
            return pagelist.ToList();
        }
        public bool Delete(int id) { 
         var zhi =Dal.Query().Where(n => n.Id == id).FirstOrDefault();
            Dal.Delete(zhi);
            return Dal.SaveChanges();
        }
    }
}
